package com.menggudf.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.menggudf.entity.Diagnosis;

@Repository
public class DiagnosisDao{

    private static final Log log = LogFactory.getLog(DiagnosisDao.class);

    @PersistenceContext(unitName = "medicalUnit")
    private EntityManager entityManager;

    public void persist(Diagnosis transientInstance) {
        try {
            entityManager.persist(transientInstance);
        } catch (RuntimeException re) {
            log.error("persist failed", re);
            throw re;
        }
    }

    public void remove(Diagnosis persistentInstance) {
        try {
            entityManager.remove(persistentInstance);
        } catch (RuntimeException re) {
            log.error("remove failed", re);
            throw re;
        }
    }

    public Diagnosis merge(Diagnosis detachedInstance) {
        try {
            Diagnosis result = entityManager.merge(detachedInstance);
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public Diagnosis findById(Long id) {
        try {
            Diagnosis instance = entityManager.find(Diagnosis.class, id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }

    public Diagnosis getDiagnosisByIllnessId(String string) {
        // TODO Auto-generated method stub
        return null;
    }
}
